Skip to content

fix(ai): typings for functionDeclaration.parameters. #8948

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Jul 8, 2025

Conversation

hsubox76
Copy link
Contributor

Fixes #8944

This fix allows passing an ObjectSchema created by Schema.object() to functionDeclaration.parameters without any TS errors. It also forbids passing a plain JSON object to functionDeclaration.parameters if it has an optionalProperties property, as that is a convenience input method and should not be passed to the backend request. Users can still use the required property.

I experimented with intercepting plain JSON objects passed to functionDeclaration.parameters and processing the optionalProperties into a required array but concluded there are too many places this needs to be done (on getGenerativeModel and on each of its methods, possibly on getImagenModel and others in the future) and it adds a lot of unneeded code for a case that can be handled simply by using Schema.object() or manually filling out the required field.

Copy link

changeset-bot bot commented Apr 18, 2025

🦋 Changeset detected

Latest commit: e449914

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@firebase/ai Patch
firebase Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@google-oss-bot
Copy link
Contributor

google-oss-bot commented Apr 18, 2025

Size Report 1

Affected Products

  • @firebase/app

    TypeBase (30de503)Merge (afd1de3)Diff
    react-native?20.4 kB? (?)
  • @firebase/auth

    TypeBase (30de503)Merge (afd1de3)Diff
    browser193 kB193 kB+122 B (+0.1%)
    cordova166 kB166 kB+122 B (+0.1%)
    main147 kB147 kB+127 B (+0.1%)
    module193 kB193 kB+122 B (+0.1%)
    react-native165 kB165 kB+127 B (+0.1%)
  • @firebase/auth-cordova

    TypeBase (30de503)Merge (afd1de3)Diff
    browser166 kB166 kB+122 B (+0.1%)
    module166 kB166 kB+122 B (+0.1%)
  • @firebase/auth-web-extension

    TypeBase (30de503)Merge (afd1de3)Diff
    browser142 kB142 kB+122 B (+0.1%)
    main159 kB160 kB+129 B (+0.1%)
    module142 kB142 kB+122 B (+0.1%)
  • @firebase/auth/internal

    TypeBase (30de503)Merge (afd1de3)Diff
    browser204 kB204 kB+122 B (+0.1%)
    main174 kB174 kB+129 B (+0.1%)
    module204 kB204 kB+122 B (+0.1%)
  • @firebase/firestore

    TypeBase (30de503)Merge (afd1de3)Diff
    browser385 kB395 kB+9.56 kB (+2.5%)
    main596 kB615 kB+19.4 kB (+3.3%)
    module385 kB395 kB+9.56 kB (+2.5%)
    react-native386 kB395 kB+9.56 kB (+2.5%)
  • @firebase/firestore-lite

    TypeBase (30de503)Merge (afd1de3)Diff
    browser114 kB116 kB+2.21 kB (+1.9%)
    main157 kB159 kB+2.31 kB (+1.5%)
    module114 kB116 kB+2.21 kB (+1.9%)
    react-native114 kB116 kB+2.21 kB (+1.9%)
  • @firebase/performance

    TypeBase (30de503)Merge (afd1de3)Diff
    browser30.6 kB31.5 kB+939 B (+3.1%)
    main31.0 kB32.0 kB+939 B (+3.0%)
    module30.6 kB31.5 kB+939 B (+3.1%)
  • @firebase/storage

    TypeBase (30de503)Merge (afd1de3)Diff
    browser58.5 kB58.5 kB+2 B (+0.0%)
    main60.0 kB60.0 kB+2 B (+0.0%)
    module58.5 kB58.5 kB+2 B (+0.0%)
  • @firebase/util

    TypeBase (30de503)Merge (afd1de3)Diff
    browser29.3 kB29.4 kB+118 B (+0.4%)
    main35.7 kB35.8 kB+118 B (+0.3%)
    module29.3 kB29.4 kB+118 B (+0.4%)
  • bundle

    40 size changes

    TypeBase (30de503)Merge (afd1de3)Diff
    auth (Anonymous)77.8 kB78.0 kB+188 B (+0.2%)
    auth (EmailAndPassword)87.9 kB88.1 kB+188 B (+0.2%)
    auth (GoogleFBTwitterGitHubPopup)109 kB109 kB+188 B (+0.2%)
    auth (GooglePopup)102 kB102 kB+188 B (+0.2%)
    auth (GoogleRedirect)102 kB102 kB+188 B (+0.2%)
    auth (Phone)95.3 kB95.5 kB+188 B (+0.2%)
    database (Append to a list of data)154 kB154 kB+107 B (+0.1%)
    database (Filtering data)153 kB153 kB+107 B (+0.1%)
    database (Listen for child events)170 kB170 kB+107 B (+0.1%)
    database (Listen for value events + Detach listeners)170 kB170 kB+107 B (+0.1%)
    database (Listen for value events)170 kB170 kB+107 B (+0.1%)
    database (Read data once)169 kB169 kB+107 B (+0.1%)
    database (Save data as transactions)172 kB172 kB+107 B (+0.1%)
    database (Sort data)155 kB155 kB+107 B (+0.1%)
    database (Write data)154 kB154 kB+107 B (+0.1%)
    firestore (CSI Auto Indexing Disable and Delete)280 kB290 kB+10.8 kB (+3.8%)
    firestore (CSI Auto Indexing Enable)280 kB290 kB+10.8 kB (+3.8%)
    firestore (Persistence)311 kB322 kB+10.5 kB (+3.4%)
    firestore (Query Cursors)256 kB260 kB+3.86 kB (+1.5%)
    firestore (Query)254 kB258 kB+3.86 kB (+1.5%)
    firestore (Read data once)242 kB247 kB+5.78 kB (+2.4%)
    firestore (Read Write w Persistence)336 kB342 kB+5.97 kB (+1.8%)
    firestore (Realtime updates)244 kB248 kB+3.99 kB (+1.6%)
    firestore (Transaction)221 kB227 kB+5.62 kB (+2.5%)
    firestore (Write data)220 kB228 kB+7.24 kB (+3.3%)
    firestore-lite (Query Cursors)109 kB111 kB+1.92 kB (+1.8%)
    firestore-lite (Query)105 kB107 kB+1.92 kB (+1.8%)
    firestore-lite (Read data once)80.6 kB82.7 kB+2.05 kB (+2.5%)
    firestore-lite (Transaction)106 kB108 kB+1.92 kB (+1.8%)
    firestore-lite (Write data)90.2 kB92.1 kB+1.92 kB (+2.1%)
    functions (call)39.4 kB39.5 kB+107 B (+0.3%)
    performance (trace)62.4 kB63.0 kB+587 B (+0.9%)
    storage (getBytes)47.2 kB47.3 kB+109 B (+0.2%)
    storage (getDownloadURL)49.2 kB49.4 kB+109 B (+0.2%)
    storage (getMetadata)48.7 kB48.8 kB+109 B (+0.2%)
    storage (list + listAll)48.1 kB48.2 kB+109 B (+0.2%)
    storage (updateMetadata)49.0 kB49.1 kB+109 B (+0.2%)
    storage (uploadBytes)53.8 kB53.9 kB+109 B (+0.2%)
    storage (uploadBytesResumable)63.8 kB63.9 kB+109 B (+0.2%)
    storage (uploadString)54.0 kB54.1 kB+109 B (+0.2%)

  • firebase

    18 size changes

    TypeBase (30de503)Merge (afd1de3)Diff
    firebase-auth-compat.js145 kB146 kB+162 B (+0.1%)
    firebase-auth-cordova.js142 kB143 kB+191 B (+0.1%)
    firebase-auth-web-extension.js125 kB125 kB+191 B (+0.2%)
    firebase-auth.js163 kB163 kB+191 B (+0.1%)
    firebase-compat.js802 kB807 kB+4.67 kB (+0.6%)
    firebase-data-connect.js22.7 kB22.8 kB+94 B (+0.4%)
    firebase-database-compat.js168 kB168 kB+94 B (+0.1%)
    firebase-database.js192 kB192 kB+94 B (+0.0%)
    firebase-firestore-compat.js347 kB351 kB+4.07 kB (+1.2%)
    firebase-firestore-lite.js137 kB139 kB+2.30 kB (+1.7%)
    firebase-firestore.js449 kB458 kB+9.62 kB (+2.1%)
    firebase-functions-compat.js14.7 kB14.8 kB+94 B (+0.6%)
    firebase-functions.js19.5 kB19.6 kB+94 B (+0.5%)
    firebase-performance-compat.js40.0 kB40.5 kB+501 B (+1.3%)
    firebase-performance-standalone-compat.js105 kB105 kB+530 B (+0.5%)
    firebase-performance.js45.5 kB46.0 kB+565 B (+1.2%)
    firebase-storage-compat.js44.2 kB44.3 kB+98 B (+0.2%)
    firebase-storage.js51.1 kB51.2 kB+96 B (+0.2%)

Test Logs

  1. https://storage.googleapis.com/firebase-sdk-metric-reports/PB5xuO1RPq.html

@google-oss-bot
Copy link
Contributor

google-oss-bot commented Apr 18, 2025

Size Analysis Report 1

This report is too large (1,400,200 characters) to be displayed here in a GitHub comment. Please use the below link to see the full report on Google Cloud Storage.

Test Logs

  1. https://storage.googleapis.com/firebase-sdk-metric-reports/GLnGOK7u21.html

@hsubox76 hsubox76 marked this pull request as ready for review April 29, 2025 18:10
@hsubox76 hsubox76 requested review from a team as code owners April 29, 2025 18:10
@hsubox76 hsubox76 force-pushed the ch-schema-type-fix branch from 24d05ab to 562735c Compare June 3, 2025 18:25
Copy link
Contributor

github-actions bot commented Jun 3, 2025

Changeset File Check ✅

  • No modified packages are missing from the changeset file.
  • No changeset formatting errors detected.

@hsubox76 hsubox76 changed the title [VertexAI] Fix typings for functionDeclaration.parameters. fix(ai): typings for functionDeclaration.parameters. Jun 3, 2025
Copy link
Contributor

@egilmorez egilmorez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LG, thanks!

@hsubox76 hsubox76 merged commit ae976d0 into main Jul 8, 2025
38 checks passed
@hsubox76 hsubox76 deleted the ch-schema-type-fix branch July 8, 2025 21:25
@google-oss-bot google-oss-bot mentioned this pull request Jul 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Vertex AI] Invalid JSON payload received. Unknown name "optionalProperties" at 'tools[0].function_declarations[0].parameters': Cannot find field.
4 participants